<template>
  <div class="app-container">
    <el-form ref="form" :model="form"  :rules="rules" label-width="150px">
      <el-card class="box-card mb8">
        <div slot="header" class="clearfix">
          <span>注册配置</span>
        </div>
        <div>
          <el-form-item label="安全问题" prop="register_questions">
            <el-input v-model="form.register_questions" type="textarea" placeholder="请输入安全问题(换行隔开)" />
          </el-form-item>
        </div>
      </el-card>
      <el-card class="box-card mb8">
        <div slot="header" class="clearfix">
          <span>提现配置</span>
        </div>
        <div>
          <el-form-item label="提现手续费" prop="withdrawal_service_fee">
            <el-input v-model="form.withdrawal_service_fee" placeholder="请输入提现手续费" style="width: 200px;"/>%
          </el-form-item>
          <el-form-item label="单次最少提现金额" prop="withdrawal_min_limit">
            <el-input v-model="form.withdrawal_min_limit" placeholder="请输入单次最少提现金额" style="width: 200px;"/>
          </el-form-item>
          <el-form-item label="单次最高提现金额" prop="withdrawal_max_limit">
            <el-input v-model="form.withdrawal_max_limit" placeholder="请输入单次最高提现金额" style="width: 200px;"/>
          </el-form-item>
        </div>
      </el-card>
      <el-card class="box-card mb8">
        <div slot="header" class="clearfix">
          <span>充值配置</span>
        </div>
        <div>
          <el-form-item label="充值最小金额" prop="recharge_min_limit">
            <el-input v-model="form.recharge_min_limit" placeholder="请输入充值最小金额" style="width: 200px;"/>
          </el-form-item>
          <el-form-item label="充值最大金额" prop="recharge_max_limit">
            <el-input v-model="form.recharge_max_limit" placeholder="请输入充值最大金额" style="width: 200px;"/>
          </el-form-item>
        </div>
      </el-card>
      <el-card class="box-card mb8">
        <div slot="header" class="clearfix">
          <span>签到设置</span>
        </div>
        <div>
          <el-form-item label="每次签到获得利息券" prop="day_signin_coupon">
            <el-input v-model="form.day_signin_coupon" placeholder="请输入每次签到获得利息券" style="width: 200px;"/>元
          </el-form-item>
          <el-form-item label="每日最多签到次数" prop="day_signins">
            <el-input v-model="form.day_signins" placeholder="请输入每日最多签到次数" style="width: 200px;"/>次
          </el-form-item>
        </div>
      </el-card>
      <el-card class="box-card mb8">
        <div slot="header" class="clearfix">
          <span>交易配置</span>
        </div>
        <div>
          <el-form-item label="交易手续费" prop="transaction_rate">
            <el-input v-model="form.transaction_rate" placeholder="请输入交易手续费" style="width: 200px;"/>%
          </el-form-item>
          <el-form-item label="最小交易手续费" prop="min_transaction_fee">
            <el-input v-model="form.min_transaction_fee" placeholder="请输入最小交易手续费" style="width: 200px;"/>元
          </el-form-item>
          <el-form-item label="交易规则" prop="transaction_rule">
            <el-input v-model="form.transaction_rule" type="textarea" placeholder="请输入交易规则"/>
          </el-form-item>
        </div>
      </el-card>
      <el-card class="box-card mb8">
        <div slot="header" class="clearfix">
          <span>其他配置</span>
        </div>
        <div>
          <el-form-item label="客服地址" prop="customer_service">
            <el-input v-model="form.customer_service" placeholder="请输入客服地址" />
          </el-form-item>
        </div>
      </el-card>
      <el-button class="mt8" type="primary" v-hasPermi="['WorkOrderController@store']" @click="submitForm">保存</el-button>
    </el-form>
  </div>
</template>

<script>
import * as Setting from "@/api/system/setting";

export default {
  name: "Setting",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 公告表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        page: 1,
        pageSize: 10,
        title: undefined,
        state: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      Setting.List().then(response => {
        this.form=response.data;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          Setting.Update({setting:this.form}).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
        }
      });
    }
  }
};
</script>
